package com.cwj;

/**
 * switch 支持 byte、float、int、char、Byte、Float、Integer、Character and String、Enum。
 * @author wujie.chen
 * 2021/9/26 14:53
 */
public class SwitchTest {
    public static void main(String[] args) {

    }
    public static void t1(){
        int i = 0;
        i = i++;
    }
    public static void t2(){
        int i = 0;
        i = ++i;
    }

    public void byteTest(byte a){
        switch (a){
            case 0x00:
                System.out.println("0");
                break;
            case 0x01:
                System.out.println("1");
                break;
            case 0x02:
                System.out.println("2");
                break;
            default:
                System.out.println("default");
        }
    }

    public void shortTest(short a){
        switch (a){
            case 0x00:
                System.out.println("0");
                break;
            case 0x01:
                System.out.println("1");
                break;
            case 0x02:
                System.out.println("2");
                break;
            default:
                System.out.println("default");
        }
    }

    public void intTest(int a){
        switch (a){
            case 0x00:
                System.out.println("0");
                break;
            case 0x01:
                System.out.println("1");
                break;
            case 0x02:
                System.out.println("2");
                break;
            default:
                System.out.println("default");
        }
    }

    public void charTest(char a){
        switch (a){
            case 0x00:
                System.out.println("0");
                break;
            case 0x01:
                System.out.println("1");
                break;
            case 0x02:
                System.out.println("2");
                break;
            default:
                System.out.println("default");
        }
    }
    public void stringTest(String a){
        switch (a){
            case "0":
                System.out.println("0");
                break;
            case "1":
                System.out.println("1");
                break;
            case "2":
                System.out.println("2");
                break;
            default:
                System.out.println("default");
        }
    }

    public void enumTest(Type a){
        switch (a){
            case A:
                System.out.println("0");
                break;
            case B:
                System.out.println("1");
                break;
            case C:
                System.out.println("2");
                break;
            default:
                System.out.println("default");
        }
    }

    private static enum Type{
        A, B, C;
    }
}
